﻿
@{
    ViewBag.Title = "alterPwd";
    Layout = "~/Views/_MasterPage.cshtml";
}
<link rel="stylesheet" type="text/css" href="~/Content/alterPwdCSS.css" />
<div class="BiaoTi"><span>修改密码</span></div>
<hr />
<div class="XG_TextK">
    <input type="text" class="YongHuMing color_Hui" />
    <span class="YongHuMingPanDuan" style="color: red;"></span>
    <input type="text" class="YouXiang color_Hui" />
    <span class="YouXiangPanDuan" style="color: red;"></span>
    <div class="YanZh">
        <input type="text" class="YanZhengMa color_Hui" maxlength="6" />
        <div class="YanZ YanZ_Ben">
            <span>获取验证码</span>
        </div>
    </div>
    <span class="YanZhengMaPanDuan" style="color: red;"></span>

    <div class="but1">确定</div>
</div>

<div class="emmm">
    @*<div class="XiuGaiM">
        <div class="Kuang">
            <div class="GuanBi">
                <div class="GB_Xian1"></div>
                <div class="GB_Xian2"></div>
            </div>
            <input type="text" class="MiMa1 color_Hui" />
            <input type="text" class="MiMa2 color_Hui" />
            <div class="Tishi"><span></span></div>
            <div class="TiJiao_XG">确定</div>
        </div>
    </div>*@
</div>
<script src="~/Scripts/jquery-3.4.1.js"></script>
<script src="~/Scripts/alterPwdJS.js"></script>
<script>
		$(function() {

			//确定
			$(".TiJiao_XG").click(function () {
				if ($(".MiMa1").val() == "" || $(".MiMa2").val() == "") {
					return;
				}
				if($(".MiMa1").val() != $(".MiMa2").val()){
					$(".Tishi>span").text("两次密码不相同");
					return;
				};
				$.post("@Url.Action("alterPwd1","MyHome")", { number: $(".YongHuMing").val(), pwd: $(".YouXiang").val(), YZM: $(".YanZhengMa").val(), pwd: $(".MiMa").val() }, function (data) {
					console.log("更改中");
					if (data.State == 1) {
						alert(data.Message);
					}
                    if (data.State == 0) {
                        alert(data.Message);
                    }

				})
			})
			$(".but1").click(function () {
				PanDuan_Kong();
				$.post("@Url.Action("alterPwd","MyHome")", { number: $(".YongHuMing").val(), pwd: $(".YouXiang").val(), YZM: $(".YanZhengMa").val() }, function (data) {
					console.log("验证中");
					if (data.State == 0) {
						$(".emmm").html(data.Message);
					}
                    if (data.State == 2) {
                        $(".YanZhengMaPanDuan").html(data.Message);
					}
                    if (data.State == 3) {
                        $(".YouXiangPanDuan").html(data.Message);
					}
                    if (data.State == 4) {
                        $(".YongHuMingPanDuan").html(data.Message);
                    }
				})
			});
			//判断
			var PanDuan_Kong = function () {
				if ($(".YongHuMing").val() == "") {
					$(".YouXiangPanDuan").text("账号不能为空");
					return;
				}
				if ($(".YouXiang").val() == "") {
					$(".YouXiangPanDuan").text("邮箱不能为空");
					return;
                }
                if ($(".YanZhengMa").val() =="") {
					$(".YanZ>span").text("验证码不能为空");
				}
				Gmail_PanDUan();
			}
			//发送验证码
			var FS_PanDuan = true;
			$(".YanZ").click(function() {
				//判断邮箱
				Gmail_PanDUan();
				if ($(".YouXiang").val() != "" && $(".YouXiang").val() != "邮箱") {
					if (FS_PanDuan == true) {
						$.post("@Url.Action("sendmailXiuGai", "MyHome")", { Gmail: $(".YouXiang").val() }, function (data) {
							if (data.State == 1) {
								console.log(data.Message);
								//发送倒计时
                                FS_PanDuan = false;
                                $(".YanZ").css("cursor", "default");
                                var YanZheng_JiShu = 60;
                                var YZM_Time = setInterval(function () {
                                    $(".YanZ>span").text(YanZheng_JiShu);
                                    if (YanZheng_JiShu == 0) {
                                        $(".YanZ").css("cursor", "pointer");
                                        YanZheng_JiShu = 5;
                                        FS_PanDuan = true;
                                        $(".YanZ>span").text("发送验证码");
                                        clearInterval(YZM_Time);
                                    }
                                    YanZheng_JiShu--;
                                }, 1000);
							}
							if (data.State == 0) {
								$(".YouXiangPanDuan").text(data.Message);
							}
							if (data.State == 2) {
                                $(".YouXiangPanDuan").html(data.Message + "<a href='~MyHome/找回密码'><sub>点击这里找回密码</sub></a>");
                            }
						})
					}
				}
			})
			//判断邮箱
			var Gmail_PanDUan = function() {
				if ($(".YouXiang").val() == "邮箱" || $(".YouXiang").val() == "") {
					$(".YouXiangPanDuan").text("请输入邮箱");
					$(".YanZhengMa").css("margin-top", "8px");
					return false;
				}
				var search_str = /^[\w\-\.]+@@[\w\-\.]+(\.\w+)+$/;
				var email_val = $(".YouXiang").val();
				if (!search_str.test(email_val)) {
					$(".YouXiangPanDuan").text("邮箱格式不正确");
					$(".YanZhengMa").css("margin-top", "8px");
					return false;
				} else {
					$(".YouXiangPanDuan").text("");
					return true;
				}
			}
		})
</script>

